import hashlib
import random
import re

ALL_CHARS = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'


def gen_md5_digest(content):
    """将字符串处理成md5照耀"""
    return hashlib.md5(content.encode()).hexdigest()


def gen_mobile_code(length=6):
    """生成6位长度的手机验证码"""
    return ''.join(random.choices('0123456789', k=length))


TEL_PATTERN = re.compile(r'1[3-9]\d{9}')


def check_tel(tel):
    """检验手机号码是否合法"""
    return TEL_PATTERN.fullmatch(tel) is not None
